﻿#pragma once

#include "../../Server/MirEnvir/Envir.h"
#include "../../Server/MirDatabase/MagicInfo.h"
#include <string>
#include <cmath>
#include <any>
#include "../../bankersrounding.h"

using namespace Server::MirDatabase;
using namespace Server::MirEnvir;

namespace Server
{
    class MagicInfoForm : public System::Windows::Forms::Form
    {

    public:
        virtual ~MagicInfoForm()
        {
            delete _selectedMagicInfo;
            delete MagiclistBox;
            delete tabControl1;
            delete tabPage1;
            delete lblBookValid;
            delete label1;
            delete txtSkillIcon;
            delete panel1;
            delete txtSkillLvl3Points;
            delete txtSkillLvl2Points;
            delete txtSkillLvl1Points;
            delete label6;
            delete label7;
            delete label8;
            delete txtSkillLvl3Req;
            delete txtSkillLvl2Req;
            delete txtSkillLvl1Req;
            delete label5;
            delete label4;
            delete label3;
            delete label2;
            delete panel2;
            delete label11;
            delete label10;
            delete label9;
            delete txtMPIncrease;
            delete txtMPBase;
            delete toolTip1;
            delete components;
            delete panel3;
            delete txtDelayReduction;
            delete txtDelayBase;
            delete label14;
            delete label13;
            delete label12;
            delete panel4;
            delete label15;
            delete lblDamageExample;
            delete txtDmgBonusMax;
            delete txtDmgBonusMin;
            delete label18;
            delete label19;
            delete txtDmgBaseMax;
            delete txtDmgBaseMin;
            delete label17;
            delete label16;
            delete lblSelected;
            delete label20;
            delete txtRange;
            delete lblDamageExplained;
            delete txtDmgMultBoost;
            delete txtDmgMultBase;
            delete label21;
            delete label22;
            delete textBoxName;
            delete label23;
            delete label24;
        }

        Server::MirEnvir::Envir *getEnvir() const;

    private:
        MagicInfo *_selectedMagicInfo;

    public:
        MagicInfoForm();

    private:
        void UpdateMagicForm(unsigned char field = 0);

        int GetMaxPower(unsigned char level);
        int GetMinPower(unsigned char level);

        void InitializeComponent();

        void MagicInfoForm_FormClosed(std::any sender, FormClosedEventArgs *e);

        void MagiclistBox_SelectedIndexChanged(std::any sender, EventArgs *e);

        bool IsValid(unsigned char &input);
        bool IsValid(unsigned short &input);

        bool IsValid(unsigned int &input);

        bool IsValid(float &input);

        void txtSkillIcon_TextChanged(std::any sender, EventArgs *e);

        void txtSkillLvl1Req_TextChanged(std::any sender, EventArgs *e);

        void txtSkillLvl2Req_TextChanged(std::any sender, EventArgs *e);

        void txtSkillLvl3Req_TextChanged(std::any sender, EventArgs *e);

        void txtSkillLvl1Points_TextChanged(std::any sender, EventArgs *e);

        void txtSkillLvl2Points_TextChanged(std::any sender, EventArgs *e);

        void txtSkillLvl3Points_TextChanged(std::any sender, EventArgs *e);

        void txtMPBase_TextChanged(std::any sender, EventArgs *e);

        void txtMPIncrease_TextChanged(std::any sender, EventArgs *e);

        void txtDmgBaseMin_TextChanged(std::any sender, EventArgs *e);

        void txtDmgBaseMax_TextChanged(std::any sender, EventArgs *e);

        void txtDmgBonusMin_TextChanged(std::any sender, EventArgs *e);

        void txtDmgBonusMax_TextChanged(std::any sender, EventArgs *e);

        void txtDelayBase_TextChanged(std::any sender, EventArgs *e);

        void txtDelayReduction_TextChanged(std::any sender, EventArgs *e);

        void txtRange_TextChanged(std::any sender, EventArgs *e);

        void txtDmgMultBase_TextChanged(std::any sender, EventArgs *e);

        void txtDmgMultBoost_TextChanged(std::any sender, EventArgs *e);

        void textBoxName_TextChanged(std::any sender, EventArgs *e);


        System::Windows::Forms::ListBox *MagiclistBox;
        System::Windows::Forms::TabControl *tabControl1;
        System::Windows::Forms::TabPage *tabPage1;
        System::Windows::Forms::Label *lblBookValid;
        System::Windows::Forms::Label *label1;
        System::Windows::Forms::TextBox *txtSkillIcon;
        System::Windows::Forms::Panel *panel1;
        System::Windows::Forms::TextBox *txtSkillLvl3Points;
        System::Windows::Forms::TextBox *txtSkillLvl2Points;
        System::Windows::Forms::TextBox *txtSkillLvl1Points;
        System::Windows::Forms::Label *label6;
        System::Windows::Forms::Label *label7;
        System::Windows::Forms::Label *label8;
        System::Windows::Forms::TextBox *txtSkillLvl3Req;
        System::Windows::Forms::TextBox *txtSkillLvl2Req;
        System::Windows::Forms::TextBox *txtSkillLvl1Req;
        System::Windows::Forms::Label *label5;
        System::Windows::Forms::Label *label4;
        System::Windows::Forms::Label *label3;
        System::Windows::Forms::Label *label2;
        System::Windows::Forms::Panel *panel2;
        System::Windows::Forms::Label *label11;
        System::Windows::Forms::Label *label10;
        System::Windows::Forms::Label *label9;
        System::Windows::Forms::TextBox *txtMPIncrease;
        System::Windows::Forms::TextBox *txtMPBase;
        System::Windows::Forms::ToolTip *toolTip1;
        System::ComponentModel::IContainer *components;
        System::Windows::Forms::Panel *panel3;
        System::Windows::Forms::TextBox *txtDelayReduction;
        System::Windows::Forms::TextBox *txtDelayBase;
        System::Windows::Forms::Label *label14;
        System::Windows::Forms::Label *label13;
        System::Windows::Forms::Label *label12;
        System::Windows::Forms::Panel *panel4;
        System::Windows::Forms::Label *label15;
        System::Windows::Forms::Label *lblDamageExample;
        System::Windows::Forms::TextBox *txtDmgBonusMax;
        System::Windows::Forms::TextBox *txtDmgBonusMin;
        System::Windows::Forms::Label *label18;
        System::Windows::Forms::Label *label19;
        System::Windows::Forms::TextBox *txtDmgBaseMax;
        System::Windows::Forms::TextBox *txtDmgBaseMin;
        System::Windows::Forms::Label *label17;
        System::Windows::Forms::Label *label16;
        System::Windows::Forms::Label *lblSelected;
        System::Windows::Forms::Label *label20;
        System::Windows::Forms::TextBox *txtRange;
        System::Windows::Forms::Label *lblDamageExplained;
        System::Windows::Forms::TextBox *txtDmgMultBoost;
        System::Windows::Forms::TextBox *txtDmgMultBase;
        System::Windows::Forms::Label *label21;
        System::Windows::Forms::Label *label22;
        System::Windows::Forms::TextBox *textBoxName;
        System::Windows::Forms::Label *label23;
        System::Windows::Forms::Label *label24;
    };
}
